package utils

import (
	"fmt"
	"net/http"
	"strings"
)

func ValidateHTTPMethod(method string) (err error, warnings []string) {
	switch strings.ToUpper(method) {
	// 常用 HTTP 方法
	case http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch:
	case http.MethodHead, http.MethodConnect, http.MethodOptions, http.MethodTrace:
		warnings = append(warnings, fmt.Sprintf("方法 %s 不常用", method))
	default:
		err = fmt.Errorf("不支持的方法 %s", method)
	}
	return
}
